package com.bigknow.appstore.web.console.controller;

import com.bigknow.appstore.web.console.app.ApplicationState;
import com.bigknow.appstore.web.console.service.ApplicationManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by 李科风 on 2016-10-25.
 */
@Controller
@RequestMapping("/sys/app")
public class ApplicationManagerController {

    @Autowired
    private ApplicationManagerService service;

    @RequestMapping
    public String index(Model model) {
        model.addAttribute("totalApp", service.getTotalAppCount());
        model.addAttribute("testApp", service.getAppCountByState(ApplicationState.TEST));
        model.addAttribute("applyingApp", service.getAppCountByState(ApplicationState.APPLYING));
        model.addAttribute("publishedApp", service.getAppCountByState(ApplicationState.PUBLISHED));
        model.addAttribute("deprecatedApp", service.getAppCountByState(ApplicationState.DEPRECATED));

        return "/sys/appIndex";
    }
}
